AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")

local isTouching = false
local timerCreated = false

function ENT:Initialize()
        self.Entity:SetModel("models/hunter/blocks/cube1x1x025.mdl")
		
		self:SetRenderMode(RENDERMODE_NORMAL)
		self:SetColor(Color(17, 245, 57, 255))
		
        self.Entity:SetSkin(0)
        self.Entity:SetSolid(SOLID_VPHYSICS)
        local phys = self.Entity:GetPhysicsObject()
        if phys and phys:IsValid() then phys:Wake() end
end

function Delay_EnableTransparency( Blox )
        Blox:SetNotSolid( true )
		Blox:SetRenderMode(RENDERMODE_TRANSALPHA)
		Blox:SetColor(Color(17, 245, 57, 150))
        timer.Simple(1, function()
			Delay_DisableTransparency(Blox)
		end)
end

function Delay_DisableTransparency( Blox )
        Blox:SetNotSolid( false )
		Blox:SetRenderMode(RENDERMODE_NORMAL)
		col = Color(17, 245, 57, 255)
        timerCreated = false
end


function ENT:SpawnFunction( ply, tr ) 
        if ( !tr.Hit ) then return end 

        local SpawnPos = tr.HitPos + tr.HitNormal * 16
        local ent = ents.Create( self.Classname )

        ent:SetPos( SpawnPos ) 
        ent:Spawn() 
        ent:Activate() 

        return ent 
end 

function ENT:StartTouch( ent )
        if ( IsValid(ent) and ent:IsPlayer() ) then
                isTouching = true
                if not timerCreated then
					local block = self.Entity
				
					timer.Simple(2, function()
						Delay_EnableTransparency(block)
						timerCreated = true
					end)
				end
        end
end


function ENT:Touch( ent )
end


function ENT:EndTouch( ent )
end

function ENT:Think()
end
